﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Framework.Logic.Information;
using Settings = Framework.Logic.Settings;

namespace Framework.Forms
{
    public partial class CommandLineArguments : Form
    {
        public CommandLineArguments()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            SaveAllocatedRAM(cmbRam.Text);
            this.Close();
            this.Dispose();
        }

        private void CommandLineArguments_Load(object sender, EventArgs e)
        {
            
            if (Settings.DataAccess.GetAllocatedRAM() == null || !Settings.DataAccess.GetAllocatedRAM().Contains("GB"))
            {
                ResetAllocatedRAM();
            }


            if (!OS.get_Is64BitOperatingSystem())
            {
                int count = cmbRam.Items.Count - 1;
                for (int i = count; i > 2; i--)
                {
                    cmbRam.Items.RemoveAt(i);
                }
                if (Settings.DataAccess.GetAllocatedRAM() != "0.5GB" || Settings.DataAccess.GetAllocatedRAM() != "1GB" || Settings.DataAccess.GetAllocatedRAM() != "0.75GB")
                {
                    ResetAllocatedRAM();
                }
            }
            cmbRam.Text = Settings.DataAccess.GetAllocatedRAM();
        }

        private void ResetAllocatedRAM()
        {
            Settings.DataAccess.SaveAllocatedRAM("1GB");
        }

        private void SaveAllocatedRAM(string strRAM)
        {
            Settings.DataAccess.SaveAllocatedRAM(strRAM);
        }
    }
}
